schema <- evaluationScheme(MovieLense, method="split", train=0.9, given=15, goodRating=3)

trainData = getData(schema, "train")
knownData = getData(schema, "known")
unknownData = getData(schema, "unknown")

tic()
rIBCF1<- Recommender(trainData, method = "IBCF", parameter=list(method="cosine", k=30, normalize="center"))
toc()
tic()
rIBCF2<- Recommender(trainData, method = "IBCF", parameter=list(method="cosine", k=30, normalize="Z-score"))
toc()
tic()
rIBCF3<- Recommender(trainData, method = "IBCF", parameter=list(method="cosine", k=10, normalize="center"))
toc()
tic()
rIBCF4<- Recommender(trainData, method = "IBCF", parameter=list(method="cosine", k=10, normalize="Z-score"))
toc()
tic()
rIBCF5<- Recommender(trainData, method = "IBCF", parameter=list(method="cosine", k=30))
toc()
tic()
rIBCF6<- Recommender(trainData, method = "IBCF", parameter=list(method="cosine", k=10))
toc()

p1 <- predict(rIBCF1, knownData, type="ratings")
p3 <- predict(rIBCF3, knownData, type="ratings")
p2 <- predict(rIBCF2, knownData, type="ratings")
p3 <- predict(rIBCF3, knownData, type="ratings")
p4 <- predict(rIBCF4, knownData, type="ratings")
p5 <- predict(rIBCF5, knownData, type="ratings")
p6 <- predict(rIBCF6, knownData, type="ratings")


error1 <- rbind(
calcPredictionError(p1, unknownData),
calcPredictionError(p2, unknownData),
calcPredictionError(p3, unknownData),
calcPredictionError(p4, unknownData),
calcPredictionError(p5, unknownData),
calcPredictionError(p6, unknownData)
)

tic()
rPOP1 <- Recommender(getData(schema, "train"), method = "POPULAR", parameter=list(aggregation=colSums))
toc()
tic()
rPOP2 <- Recommender(getData(schema, "train"), method = "POPULAR", parameter=list(aggregation=colMeans))
toc()
p1 <- predict(rPOP1, knownData, type="ratings")
p2 <- predict(rPOP2, knownData, type="ratings")

error1 <- rbind(
calcPredictionError(p1, unknownData),
calcPredictionError(p2, unknownData)
)
